package thread;
/**
 * Created with IntelliJ IDEA.
 * Description:饿汉模式
 * User: wx
 * Date: 2023-11-29
 * Time: 21:37
 */
public class Tsetdemo {
    public static void main(String[] args) {

        int[] nums = {3,2,2,3};

        removeElement(nums,3);
    }

    public static int removeElement(int[] nums, int val) {
        int left = 0;
        int size = nums.length;
        while(left < size){
            if(nums[left] == val ){
                nums[left] = nums[size - 1];
                size--;
            }else{
                left++;
            }
        }
        return left;

    }
}
